home *** CD-ROM | disk | FTP | other *** search
/ Mac Expert 1995 Winter / Mac Expert - Winter 95.iso / Les fichiers / Utilitaires divers / Divers / NeXT WDef III 3.1 ƒ / Source / TrUE NeXT.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-21  |  33.3 KB  |  1,215 lines  |  [TEXT/KAHL]

  1. /*
  2.             ——————————————————————————————
  3.             My Window Definition Procedure
  4.             ——————————————————————————————
  5.             
  6.             This is that odd window.
  7.             
  8.             ————————
  9.             89/04/20
  10.             ————————
  11.             
  12.             1.0      89/03/31    First draft based on clock window def proc (+A5 games ).
  13.                   89/04/05    Fixed problem with zoom box hilite
  14.                   89/04/06    Fixed zooming
  15.                   89/04/07    Minor changes in draw, chose from two gray patterns
  16.                             to avoid odd mismatches in window dragged onscreen 
  17.                             from offscreen, added proper plainDBox & altDBoxProc 
  18.                             variations, special cased zero width titles.
  19.             1.1      89/04/09    Odd half erased scroll bar startup MPW adjusted
  20.                             [see DrawMyGrowIcon()]
  21.             1.2      89/04/09    Fixed problem with userState updates. Working on colors!
  22.                   89/04/11    Changed size box to chevrons.
  23.                   89/04/12    Made sure inGrow only returned on hilited windows.
  24.                   89/04/20    Added Apples screenBits workaround and scroll area 
  25.                               to grow image.
  26.             2.0   89/11/10  Finished color additions and cleaned up other
  27.                             assorted bugs. JNP
  28.             
  29.                             Changes made by Josh Pritikin ( 11.10.89 ):
  30.                     1. In CalculateMyWindow I added a test to see if we have a color window.
  31.                     2. I removed the ugly StuffHex calls and speeded the pattern packing up.
  32.                     3. I added a gunk of code and special casing to totally support ColorQD!
  33.                     4. The code is admitably gross in some (most) places but it works and should
  34.                         serve as an example of what not to make your code look like.
  35.  
  36.                         GEnie:            J.Pritikin
  37.                         AppleLink:        D4991    ( <- this will change soon )
  38.                         Internet:        6500stom@ucsbuxa.ucsb.edu
  39.                         
  40.             3.0   93/03/22    Updated for full color support. Rewrote code for Think C 5.x.
  41.                             
  42.                             Changes made by Anthony D. Saxton ( 2/26/93 ):
  43.                     1.    Rewrote code throughout for more efficient use of Think C 5.x.
  44.                     2.    Added Color button Icons for 2, 4 and 8 bit modes.
  45.                     3.    Added support for colorized windows as well as Apples "Color" cdev.
  46.                     4.    Added support for ALL documented window types & frames for the others!
  47.                     5.    Corrected Icon bug and added 3D movement!
  48.                     6.    Corrected GoAway button presence in movable dialog windows.
  49.             
  50.             3.1      93/04/13    Converted NeXT WDEF to TrUE NeXT WDEF.
  51.                             Corrected some memory wasting code.
  52.                             Converted the Icon Color Table to a global.
  53.                             Corrected Colors in 2-bit mode.
  54.             
  55.                     
  56.         The Copyright Notice in “CopyRight()” Is Not To Be Removed! Use Of This Code In
  57.         Commercial Software By License Only. Contact Anthony D. Saxton, Of Elenay™ Creations
  58.         For Licensing Information. Use Of This Code In FreeWare, Requires Only Contact Of
  59.         Elenay™ Creations. This Copyright Applies To All Code Segments Of This WDEF. 
  60.         
  61.         All Changes Are Copyright ©1993, by Elenay Creations
  62.                                             5686 Big Sea Street
  63.                                             Las Vegas, NV, USA
  64.                                                                 89110
  65.                                             (702) 453-0270
  66.                             
  67.                         AOL:            Elenay
  68.                         Internet:        elenay_creations@tcs.las-vegas.nv.us
  69.             
  70.             —————————————————————————————————————————————————
  71.               Public Domain 1989 by Appropriate Technology
  72.             —————————————————————————————————————————————————
  73.             Changes - Copyright ©1993 by Elenay™ Creations
  74.             —————————————————————————————————————————————————
  75.             
  76.             Please send a copy of changes/improvements to:
  77.             
  78.             Eric Celeste, Appropriate Technology, 358 North Parkview, Columbus, OH 43209, USA.
  79.             CompuServe: 76146,724. MacNET: Celeste.
  80.             
  81.             ——————————————————————————————————————————————————————————————————————
  82.             Note: This WDEF is coded in THINK C 5.0.3 from Think Technologies
  83.             ——————————————————————————————————————————————————————————————————————
  84.  
  85.  
  86. */
  87.  
  88. #include "TrUE NeXT.h"
  89.  
  90. pascal long main( int variation, WindowPtr window, int message, long parameter )
  91. {
  92.     long    result = 0L;            /* the return code for the function */
  93.     THz        saveZone;
  94.     
  95.     saveZone = GetZone();
  96.     if ( MFRunning() )
  97.         SetZone( SystemZone() );
  98.     
  99.     switch( message ) 
  100.     {
  101.     case( wDraw ):
  102.         DrawMyWindow( variation, window, parameter );
  103.         break;
  104.     case( wHit ):
  105.         result = HitMyWindow( variation, window, parameter );
  106.         break;
  107.     case( wCalcRgns ):
  108.         CalculateMyWindow( variation, window, parameter );
  109.         break;
  110.     case( wNew ):
  111.         SetupWindow( variation, window, parameter );
  112.         break;
  113.     case( wDispose ):
  114.         KillWindow( variation, window, parameter );
  115.         break;
  116.     case( wGrow ):
  117.         GrowMyWindow( variation, window, parameter );
  118.         break;
  119.     case( wDrawGIcon ):
  120.         DrawMyGrowIcon( variation, window, parameter );
  121.         break;
  122.     }
  123.     
  124.     SetZone( saveZone );
  125.     return( result );
  126. }
  127.  
  128. /*————————————————————
  129.             is MultiFinder Running?
  130. ————————————————————*/
  131. Boolean    MFRunning()
  132. {
  133.     Boolean        result;
  134.     SysEnvRec    theWorld;
  135.     
  136.     result = false;
  137.     if ( !SysEnvirons( 1, &theWorld ) )
  138.         result = ( theWorld.machineType >= 0 ) &&
  139.                     ( NGetTrapAddress( OSDispatchTrapNum, ToolTrap ) !=
  140.                                                 NGetTrapAddress( UnImplTrapNum, ToolTrap ) );
  141.     return( result );
  142. }
  143.  
  144. /*————————————————————
  145.             create an RGB gray of this brightness.
  146. ————————————————————*/
  147. RGBColor PackGray( int brightness )
  148. {
  149.     RGBColor    gray;
  150.     
  151.     gray.red =  brightness;
  152.     gray.green =  brightness;
  153.     gray.blue = brightness;
  154.     return gray;
  155. }
  156.  
  157. /*————————————————————
  158.             where was my window hit?
  159. ————————————————————*/
  160. long HitMyWindow( int variation, WindowPtr window, long parameter )
  161. {
  162.     Point    hitLocation;
  163.     long    result;
  164.     
  165.     result = wNoHit;
  166.     
  167.     SetPt( &hitLocation, LoWord( parameter ), HiWord( parameter ) );
  168.     
  169.     if ( PtInRgn( hitLocation, theWindow.strucRgn ) )
  170.     {
  171.         Rect    windowRect,
  172.                 thisRect;
  173.                 
  174.         windowRect = (**theWindow.strucRgn).rgnBBox;
  175.         
  176.         if ( PtInRgn( hitLocation, theWindow.contRgn ) )
  177.         {
  178.             result = wInContent;                    /* in the content region */
  179.             
  180.             if ( theWindow.hilited )
  181.                 if ( (variation & 7) == documentProc )
  182.                 {
  183.                     SetRect( &thisRect,
  184.                         windowRect.right - 17,
  185.                         windowRect.bottom - 17,
  186.                         windowRect.right - 3,
  187.                         windowRect.bottom - 3
  188.                     );
  189.                     if ( PtInRect( hitLocation, &thisRect ) )
  190.                         result = wInGrow;
  191.                 }
  192.         } else
  193.         {
  194.             switch( variation & 7 )
  195.             {
  196.             case( documentProc ):
  197.             case( noGrowDocProc ):
  198.             case( movableDBoxProc ):
  199.             
  200.                 result = wInDrag;                        /* in the drag area unless */
  201.                 
  202.                 if ( theWindow.hilited )
  203.                 {
  204.                     if ( theWindow.goAwayFlag && variation != movableDBoxProc )
  205.                     {
  206.                         SetRect( &thisRect,
  207.                             windowRect.right - 16,
  208.                             windowRect.top + 5,
  209.                             windowRect.right - 3,
  210.                             windowRect.top + 18
  211.                         );
  212.                         if ( PtInRect( hitLocation, &thisRect ) )
  213.                             result = wInGoAway;
  214.                     }
  215.                     if ( result == wInDrag && theWindow.zoomFlag )
  216.                     {
  217.                         SetRect( &thisRect,
  218.                             windowRect.left + 6,
  219.                             windowRect.top + 5,
  220.                             windowRect.left + 19,
  221.                             windowRect.top + 18
  222.                         );
  223.                         if ( PtInRect( hitLocation, &thisRect ) && theWindow.dataHandle  )
  224.                         {
  225.                             thisRect = (**theWindow.contRgn).rgnBBox;
  226.                             if ( EqualRect ( &(wDataHandle.stdState), &thisRect ) )
  227.                                 result = wInZoomIn;
  228.                             else
  229.                             {
  230.                                 wDataHandle.userState = thisRect;
  231.                                 result = wInZoomOut;
  232.                             }
  233.                         } /* in the zoom box */
  234.                         
  235.                     } /* still dragging & zoomable */
  236.                     
  237.                 } /* a hilited window */
  238.                 
  239.                 if ( result == wInDrag )
  240.                 {
  241.                     thisRect = windowRect;
  242.                     thisRect.top = (**theWindow.contRgn).rgnBBox.top;
  243.                     if ( PtInRect( hitLocation, &thisRect ) )
  244.                         result = wNoHit;                    // according to Apple's specs
  245. //                        result = wInContent;                // alternate result
  246.                 } /* below title bar */
  247.                 break;
  248.                 
  249.             }    /* a moveable window */
  250.             
  251.         } /* else not in content region */
  252.         
  253.     } /* in the structure region */
  254.     
  255.     return( result );
  256. } /* end of HitMyWindow() */
  257.  
  258. /*————————————————————
  259.             calculate the regions of my window
  260. ————————————————————*/
  261. CalculateMyWindow( int variation, WindowPtr window, long parameter )
  262. {
  263.     Rect    windowRect;
  264.     
  265.     windowRect = window->portRect;
  266.                                             /* a fix for CWindowRecords */
  267.     if( window->portBits.rowBytes < colorWindow ) /* Color Window? */
  268.         OffsetRect( &windowRect, -window->portBits.bounds.left, -window->portBits.bounds.top );
  269.     else
  270.     {
  271.         Rect    portR;
  272.         
  273.         portR = (**(*(CWindowPtr)window).portPixMap).bounds;
  274.         OffsetRect( &windowRect,-portR.left, -portR.top );
  275.     }
  276.     
  277.     RectRgn( theWindow.contRgn, &windowRect );
  278.     
  279.     if ( (variation & 8) && !EqualRect( &(wDataHandle.stdState),&windowRect ) )
  280.         wDataHandle.userState = windowRect;
  281.  
  282.     switch ( variation & 7 )
  283.     {
  284.     case ( documentProc ):                        /* a regular window */
  285.     case ( noGrowDocProc ):                        /* a regular window with no growing */
  286.     case ( movableDBoxProc ):                    /* a moveable dialog with no growing or close*/
  287.         OpenRgn();
  288.             InsetRect( &windowRect, -1, -1 );
  289.             windowRect.top -= 20;                /* add room for the title bar */
  290.             MoveTo( windowRect.left, windowRect.top );
  291.             LineTo( windowRect.left, windowRect.bottom-1 );
  292.             LineTo( windowRect.left+1, windowRect.bottom );
  293.             LineTo( windowRect.right, windowRect.bottom );
  294.             LineTo( windowRect.right, windowRect.top+1 );
  295.             LineTo( windowRect.right-1, windowRect.top );
  296.             LineTo( windowRect.left, windowRect.top );
  297.         CloseRgn( theWindow.strucRgn );
  298.         break;
  299.     case ( dBoxProc ):                            /* dialog box variation */
  300.         OpenRgn();
  301.             InsetRect( &windowRect, -8, -8 );
  302.             MoveTo( windowRect.left, windowRect.top );
  303.             LineTo( windowRect.left, windowRect.bottom-2 );
  304.             LineTo( windowRect.left+2, windowRect.bottom );
  305.             LineTo( windowRect.right, windowRect.bottom );
  306.             LineTo( windowRect.right, windowRect.top+2 );
  307.             LineTo( windowRect.right-2, windowRect.top );
  308.             LineTo( windowRect.left, windowRect.top );
  309.         CloseRgn( theWindow.strucRgn );
  310.         break;
  311.     case ( altDBoxProc ):                        /* shadow box variation */
  312.     case ( altDBoxProc + 4 ):                    /* remain consistant W/ Apple */
  313.         OpenRgn();
  314.             InsetRect( &windowRect, -1, -1 );
  315.             MoveTo( windowRect.left, windowRect.top );
  316.             LineTo( windowRect.left, windowRect.bottom );
  317.             LineTo( windowRect.left+2, windowRect.bottom );
  318.             LineTo( windowRect.left+2, windowRect.bottom+2 );
  319.             LineTo( windowRect.right+2, windowRect.bottom+2 );
  320.             LineTo( windowRect.right+2, windowRect.top+2 );
  321.             LineTo( windowRect.right, windowRect.top+2 );
  322.             LineTo( windowRect.right, windowRect.top );
  323.             LineTo( windowRect.left, windowRect.top );
  324.         CloseRgn( theWindow.strucRgn );
  325.         break;
  326.     default:                                /* plain box variation (plainDBox) and others */
  327.         InsetRect( &windowRect, -1, -1 );
  328.         RectRgn( theWindow.strucRgn, &windowRect );
  329.         break;
  330.     }
  331.         
  332. } /* end of CalculateMyWindow() */
  333.  
  334. /*————————————————————
  335.             set up the window
  336. ————————————————————*/
  337. SetupWindow( int variation, WindowPtr window, long parameter )
  338. {
  339.     theWindow.dataHandle = nil;
  340.     
  341.     theWindow.dataHandle = NewHandle( (long)sizeof( WSDRecord ) );
  342.     wCTHandle = nil;                                    // initialize CTable
  343.         
  344.     if ( variation == ( documentProc+8 ) || variation == ( noGrowDocProc+8 ) ||
  345.                                                             variation == ( movableDBoxProc+8 ) )
  346.     {
  347.         theWindow.zoomFlag = true;
  348.         if ( theWindow.dataHandle )
  349.         {        
  350.             OSErr        err;
  351.             SysEnvRec    thisWorld;
  352.             Rect        thisRect;
  353.             
  354.             err = SysEnvirons( 1, &thisWorld );
  355.             if ( !err && thisWorld.hasColorQD )
  356.             {
  357.                 GDHandle    thisDevice;
  358.                 
  359.                 thisDevice = GetMainDevice();
  360.                 thisRect = (**thisDevice).gdRect;
  361.                 thisRect.top += MBarHeight;
  362.             } else
  363.             {
  364.                 GrafPtr        savePort;
  365.                 GrafPort    tempPort;
  366.                 
  367.                 GetPort( &savePort );                /* finding screenBits w/o globals */
  368.                 OpenPort( &tempPort );
  369.                 thisRect = tempPort.portRect;
  370.                 SetPort( savePort ); 
  371.                 ClosePort( &tempPort );
  372.                 thisRect.top += MBarHeight;            /* make way for the menubar */
  373.             }
  374.             InsetRect( &thisRect, 2, 2 );            /* make way for edges */
  375.             thisRect.top += 16;                        /* make way for what's left of title */
  376.             wDataHandle.stdState = thisRect;
  377.             wDataHandle.userState = thisRect;
  378.         }
  379.     } else
  380.         theWindow.zoomFlag = false;
  381.         
  382.     buttonState = 0;
  383.     
  384. } /* end of SetupWindow() */
  385.  
  386. /*————————————————————
  387.             kill the window
  388. ————————————————————*/
  389. KillWindow( int variation, WindowPtr window, long parameter )
  390. {
  391.     if ( theWindow.dataHandle  )
  392.     {
  393.         if ( wCTHandle )
  394.         {
  395.             DisposeHandle( wCTHandle );
  396.             wCTHandle = nil;
  397.         }
  398.         DisposHandle( theWindow.dataHandle );
  399.         theWindow.dataHandle = nil;
  400.     }
  401. } /* end of KillWindow() */
  402.  
  403. /*————————————————————
  404.             draw the growing outline, the pen is already set
  405. ————————————————————*/
  406. GrowMyWindow( int variation, WindowPtr window, long parameter )
  407. {
  408.     Rect        growingRect;
  409.     
  410.     growingRect = *(RectPtr)parameter;
  411.     
  412.     growingRect.top -= 21;                                    /* out to full size */
  413.     growingRect.left -= 1;
  414.     growingRect.bottom += 1;
  415.     growingRect.right += 1;
  416.     
  417.     FrameRect( &growingRect );                                /* the frame */
  418.     
  419.     growingRect.top += 20;
  420.     
  421.     MoveTo( growingRect.left, growingRect.top );            /* the title bar area */
  422.     LineTo( growingRect.right, growingRect.top );
  423.     
  424.     MoveTo( growingRect.right - 16, growingRect.top );         /* the scroll area */
  425.     LineTo( growingRect.right - 16, growingRect.bottom );
  426.     MoveTo( growingRect.left, growingRect.bottom - 17 );
  427.     LineTo( growingRect.right, growingRect.bottom - 17 );
  428.     
  429. } /* end of GrowMyWindow() */
  430.  
  431. /*————————————————————
  432. draw the size box and the scroll frame
  433. ————————————————————*/
  434. DrawMyGrowIcon( int variation, WindowPtr window, long parameter )
  435. {
  436.     SysEnvRec        thisWorld;
  437.     Boolean            hasColorQD;
  438.     Rect            thisRect;
  439.     RGBColor        myRGB;
  440.     RgnHandle        saveClip,
  441.                     tempRgn;
  442.     
  443.     
  444.     SetPort( window );
  445.     
  446.     if ( !SysEnvirons( 1, &thisWorld ) )
  447.         hasColorQD = thisWorld.hasColorQD;
  448.     else
  449.         hasColorQD = false;
  450.     
  451.     if ( hasColorQD )
  452.     {
  453.         AuxWinHandle    theAuxWin;
  454.         
  455.         theAuxWin = nil;
  456.         GetAuxWin( window, &theAuxWin );
  457.         if ( theAuxWin )
  458.         {
  459.             
  460. /*        The code below makes sure the System 7 colors are found even when the window color
  461.             table is defined with only 5 colors! This determines if the Grow Icon will be drawn
  462.             in color or b/w. */
  463.                 
  464.             if ( auxCTable->ctSize < 12 )
  465.                 GetAuxWin( nil, &theAuxWin );
  466.                 
  467.             if ( auxCTable->ctSize >= 12 )
  468.                 myRGB =  auxCTable->ctTable[12].rgb;
  469.             else
  470.                 myRGB.red = 0xFFFF;                // Don't force b/w if Color cdev not used…
  471.         }
  472.     }
  473.     
  474. /*————————————————————
  475. draw scroll bar frame
  476. ————————————————————*/
  477.     thisRect = window->portRect;
  478.     thisRect.left = thisRect.right - 15;
  479.     MoveTo( thisRect.left, thisRect.top );
  480.     LineTo( thisRect.left, thisRect.bottom );
  481.  
  482.     thisRect.top = thisRect.bottom - 15;
  483.     thisRect.left = window->portRect.left;
  484.     MoveTo( thisRect.left, thisRect.top );
  485.     LineTo( thisRect.right, thisRect.top );
  486.     
  487.     thisRect.left = thisRect.right - 15;
  488.     InsetRect( &thisRect, 1, 1 );
  489.     EraseRect( &thisRect );
  490.     
  491.     /*————————————————————
  492.     draw the sizing box 
  493.     ————————————————————*/
  494.  
  495.     saveClip = NewRgn();
  496.     tempRgn = NewRgn();
  497.     GetClip( saveClip );
  498.     
  499.     if ( hasColorQD && window->portBits.rowBytes < colorWindow )    // Color Window?
  500.     {
  501.         CGrafPtr    wPort;
  502.         
  503.         thisRect = (**theWindow.contRgn).rgnBBox;
  504.         thisRect.left = thisRect.right - 13;
  505.         thisRect.top = thisRect.bottom - 13;
  506.         OffsetRect( &thisRect, -1, -1 );    
  507.         GetCWMgrPort( &wPort );
  508.         SetPort( wPort );
  509.     }
  510.     
  511.     if ( theWindow.hilited )
  512.     {
  513.         if( hasColorQD )
  514.         {
  515.             GDHandle    aDevice;
  516.             
  517.             aDevice = GetDeviceList();
  518.             do
  519.             {
  520.                 if ( TestDeviceAttribute( aDevice, screenDevice ) &&
  521.                                                     TestDeviceAttribute( aDevice, screenActive ) )
  522.                 {
  523.                     HLockHi( aDevice );
  524.                     if ( RectInRgn( &(**aDevice).gdRect, saveClip ) )
  525.                     {
  526.                         Handle    theColors;
  527.                         
  528.                         theColors = wCTHandle;
  529.                         RectRgn( tempRgn, &(**aDevice).gdRect );
  530.                         SectRgn( saveClip, tempRgn, tempRgn );
  531.                         SetClip( tempRgn );
  532.                         if ( (**(**aDevice).gdPMap).cmpSize >= 2 && (myRGB.red+myRGB.green))
  533.                             PlotCICN( thisRect,
  534.                                 "\xAA\xAA\xAA\x80\x95\x55\x55\x40\x9F\xFD\x55\x40\x9C"
  535.                                 "\x0F\xFD\x40\x9C\x6C\x0D\x40\x9C\xAD\x6D\x40\x9F\xFD"
  536.                                 "\x6D\x40\x97\x15\x6D\x40\x97\x15\x6D\x40\x97\x2A\xAD"
  537.                                 "\x40\x97\xFF\xFD\x40\x95\x55\x55\x40\x95\x55\x55\x40",
  538.                             (**(**aDevice).gdPMap).cmpSize >= 4 ? theColors : nil );                        // The Color Grow Icon!
  539.                         else
  540.                             PlotSICN( thisRect, 
  541.                                 "\xFF\xF8\xAA\xA8\xFF\x50\xA3\xE8\xE6\x30\xAE\x68\xFE\x70"
  542.                                 "\xB0\x68\xD0\x70\xB7\xE8\xDF\xF0\xAA\xA8\xD5\x50\x00\x00"
  543.                             );                                        // The b/w Grow Icon!
  544.                         }
  545.                     HUnlock( aDevice );
  546.                 }
  547.             } while ( aDevice = GetNextDevice( aDevice ) );
  548.         } else
  549.             PlotSICN( thisRect, 
  550.                 "\xFF\xF8\xAA\xA8\xFF\x50\xA3\xE8\xE6\x30\xAE\x68\xFE\x70"
  551.                 "\xB0\x68\xD0\x70\xB7\xE8\xDF\xF0\xAA\xA8\xD5\x50\x00\x00"
  552.             );                                                    // The b/w Grow Icon Again!
  553.     }
  554.     
  555.     SetClip( saveClip );
  556.     DisposeRgn( saveClip );
  557.     DisposeRgn( tempRgn );
  558.  
  559.     SetPort( window );
  560.  
  561. } /* end of DrawMyGrowIcon() */
  562.  
  563. /*————————————————————
  564.             draw the frame w/ color shadowing.
  565. ————————————————————*/
  566. DrawFrame( PatsPtr pat, Rect frame, int width, int drawColor )
  567. {
  568.     frame.right -= 2;
  569.     frame.bottom -= 2;
  570.     
  571.     PenSize( width, width );
  572.     if ( drawColor )
  573.         RGBForeColor( drawColor - 1 ? &pat->cFrameL : &pat->cWhite );
  574.     else
  575.         PenPat( &pat->white );
  576.     FrameRect( &frame );
  577.     
  578.     OffsetRect( &frame, 2, 2 );
  579.     if ( drawColor  )
  580.         RGBForeColor( drawColor - 1 ? &pat->cFrameD : &pat->cDark );
  581.     else
  582.         PenPat( &pat->black );
  583.     FrameRect( &frame );
  584.  
  585.     OffsetRect( &frame, -1, -1 );
  586.     if ( drawColor )
  587.         RGBForeColor( &pat->cLight );
  588.     else
  589.         PenPat( &pat->gray );
  590.     FrameRect( &frame );
  591. } /* end of DrawFrame() */
  592.  
  593. /*————————————————————
  594.             draw an empty pane w/ shadowing
  595. ————————————————————*/
  596. DrawPane( PatsPtr pat, Rect thisRect, int drawColor )
  597. {
  598.     /* fill the area with white */
  599.     if ( drawColor )
  600.     {
  601.         RGBForeColor( drawColor - 1 ? &pat->cFrameL : &pat->cWhite );
  602.         PenPat( &pat->black );
  603.     } else
  604.         PenPat( &pat->white );
  605.     PaintRect( &thisRect );
  606.     
  607.     /* add the bottom shadow */
  608.     PenSize( 1, 1 );
  609.     if ( drawColor )
  610.         RGBForeColor( &pat->cLight );
  611.     else
  612.         PenPat( &pat->black );
  613.     MoveTo( thisRect.left+1, thisRect.bottom-1 );
  614.     LineTo( thisRect.right-1, thisRect.bottom-1 );
  615.     LineTo( thisRect.right-1, thisRect.top+1 );
  616.     
  617.     /* add the top shadow */
  618.     if ( drawColor )
  619.         RGBForeColor( drawColor - 1 ? &pat->cFrameD : &pat->cDark );
  620.     MoveTo( thisRect.left, thisRect.bottom-1 );
  621.     LineTo( thisRect.left, thisRect.top );
  622.     LineTo( thisRect.right-1, thisRect.top );
  623. } /* end of DrawPane() */
  624.  
  625. /*————————————————————
  626.             draw the title into the pane.
  627. ————————————————————*/
  628. DrawWindowTitle( WindowPtr window, Rect titleRect, PatsPtr pat, Boolean hilited, int drawColor )
  629. {
  630.     int            saveFont,
  631.                 saveSize;
  632.     Style        saveFace;
  633.     Str255        windowTitle;
  634.     int            titleWidth, titleCenter;
  635.     GrafPtr        wPort;
  636.     
  637.     GetPort( &wPort );
  638.     saveFont = wPort->txFont;
  639.     saveSize = wPort->txSize;
  640.     saveFace = wPort->txFace;
  641.  
  642.     if ( drawColor )
  643.     {
  644.         TextFont( helvetica );
  645.         TextSize( 12 );
  646.         TextFace( bold );
  647.     }else
  648.     {
  649.         TextFont( geneva );
  650.         TextSize( 9 );
  651.         TextFace( plain );
  652.     }
  653.     GetWTitle( window, windowTitle );
  654.     
  655.     titleWidth = StringWidth( windowTitle );
  656.     titleCenter = titleRect.left + ((titleRect.right - titleRect.left) / 2);
  657.     
  658.     if ( titleWidth > 0 )
  659.     {
  660.         RgnHandle    saveClip,
  661.                     myClip;
  662.  
  663.         titleWidth += 12;                        /* enough for edges */
  664.     
  665.         if ( (titleRect.right - titleRect.left) > titleWidth )
  666.         {
  667.             titleRect.right = titleCenter + titleWidth/2;
  668.             titleRect.left = titleCenter - titleWidth/2;
  669.         }
  670.         if ( hilited && !drawColor ) DrawPane( pat, titleRect, drawColor );
  671.         
  672.         /* now shrink the box & set the clip region in case of a long title */
  673.         saveClip = NewRgn();
  674.         myClip = NewRgn();
  675.         GetClip( saveClip );
  676.         if ( !drawColor )
  677.             InsetRect( &titleRect, 1, 1 );
  678.         RectRgn( myClip, &titleRect );
  679.         SectRgn( saveClip, myClip, myClip );
  680.         SetClip( myClip );
  681.         
  682.         /* now position ourselves & draw the title */
  683.         PenPat( &pat->black );
  684.         if ( drawColor )
  685.         {
  686.             if ( hilited )
  687.             {
  688.                 RGBForeColor( drawColor - 1 ? &pat->cFrameL : &pat->cWhite );
  689.                 RGBBackColor( &pat->cBlack );
  690.             } else
  691.             {
  692.                 RGBForeColor( drawColor - 1 ? &pat->cFrameD : &pat->cDark );
  693.                 RGBBackColor( &pat->cLight );
  694.             }
  695.         }
  696.         
  697.         MoveTo( titleRect.left + 6, titleRect.bottom - 2 - (drawColor>0) );
  698.         DrawString( windowTitle );
  699.         
  700.         SetClip( saveClip );
  701.         DisposeRgn( saveClip );
  702.         DisposeRgn( myClip );
  703.                 
  704.     } /* enough of a title to go with */
  705.     
  706.     TextFont( saveFont );
  707.     TextSize( saveSize );
  708.     TextFace( saveFace );
  709. } /* end of DrawWindowTitle() */
  710.  
  711. /*————————————————————
  712.             animate the close icon.
  713. ————————————————————*/
  714. DrawGoAway( Rect frame, Boolean hilited, int drawColor, Handle theColors )
  715. {
  716.     if ( hilited  )
  717.     {
  718.         if ( drawColor )
  719.             PlotCICN( frame,
  720.                         "\xAA\xAA\xAA\x80\x80\x00\x00\x00\x8A\x00\x28\x00\x8B"
  721.                         "\x80\xB8\x00\x82\xE2\xE0\x00\x80\xBB\x80\x00\x80\x2E"
  722.                         "\x00\x00\x80\xBB\x80\x00\x82\xE2\xE0\x00\x8B\x80\xB8"
  723.                         "\x00\x8A\x00\x28\x00\x80\x00\x00\x00\x80\x00\x00\x00",
  724.                         drawColor - 1 ? theColors : nil );    // goAwayDown
  725.         else
  726.             PlotSICN( frame,
  727.                         "\xFF\xF8\xAA\xA0\xD5\x50\xBA\xE0\xDD\xD0\xAF\xA0\xD7\x50"
  728.                         "\xAF\xA0\xDD\xD0\xBA\xE0\xD5\x50\xAA\xA0\x80\x00\x00\x00"
  729.                     );    // goAwayDown (b/w)
  730.     } else
  731.     {
  732.         if ( drawColor )
  733.             PlotCICN( frame,
  734.                         "\x00\x00\x00\x00\x15\x55\x55\x80\x1A\x55\x69\x80\x1B"
  735.                         "\x95\xB9\x80\x16\xE6\xE5\x80\x15\xBB\x95\x80\x15\x6E"
  736.                         "\x55\x80\x15\xBB\x95\x80\x16\xE6\xE5\x80\x1B\x95\xB9"
  737.                         "\x80\x1A\x55\x69\x80\x15\x55\x55\x80\x2A\xAA\xAA\x80",
  738.                         drawColor - 1 ? theColors : nil );    // goAwayUp
  739.         else
  740.             PlotSICN( frame,
  741.                         "\x00\x00\x2A\xA8\x55\x58\x3A\xE8\x5D\xD8\x2F\xA8\x57\x58"
  742.                         "\x2F\xA8\x5D\xD8\x3A\xE8\x55\x58\x2A\xA8\x7F\xF8\x00\x00"
  743.                     );    //    goAwayUp (b/w)
  744.     }
  745. } /* end of DrawGoAway() */
  746.  
  747. /*————————————————————
  748.             animate the zoom icon.
  749. ————————————————————*/
  750. DrawZoom( Rect frame, Boolean hilited, int drawColor, Handle theColors )
  751. {
  752.     if ( hilited )
  753.     {
  754.         if ( drawColor )
  755.             PlotCICN( frame,
  756.                         "\xAA\xAA\xAA\x80\x80\x00\x00\x00\x8F\xFF\xFC\x00\x8F"
  757.                         "\xFF\xFC\x00\x8F\xFF\xFC\x00\x8D\x55\x5C\x00\x8D\x55"
  758.                         "\x5C\x00\x8D\x55\x5C\x00\x8D\x55\x5C\x00\x8D\x55\x5C"
  759.                         "\x00\x8F\xFF\xFC\x00\x80\x00\x00\x00\x80\x00\x00\x00",
  760.                         drawColor - 1 ? theColors : nil );    //    zoomDown
  761.         else
  762.             PlotSICN( frame,
  763.                         "\xFF\xF8\xAA\xA0\xFF\xF0\xBF\xE0\xFF\xF0\xA0\x20\xE0\x30"
  764.                         "\xA0\x20\xE0\x30\xA0\x20\xFF\xF0\xAA\xA0\x80\x00\x00\x00"
  765.                     );    //    zoomDown (b/w)
  766.     } else
  767.     {
  768.         if ( drawColor )
  769.             PlotCICN( frame,
  770.                         "\x00\x00\x00\x00\x15\x55\x55\x80\x1F\xFF\xFD\x80\x1F"
  771.                         "\xFF\xFD\x80\x1F\xFF\xFD\x80\x1D\x55\x5D\x80\x1D\x55"
  772.                         "\x5D\x80\x1D\x55\x5D\x80\x1D\x55\x5D\x80\x1D\x55\x5D"
  773.                         "\x80\x1F\xFF\xFD\x80\x15\x55\x55\x80\x2A\xAA\xAA\x80",
  774.                         drawColor - 1 ? theColors : nil );    //    zoomUp
  775.         else
  776.             PlotSICN( frame,
  777.                         "\x00\x00\x2A\xA8\x7F\xF8\x3F\xE8\x7F\xF8\x20\x28\x60\x38"
  778.                         "\x20\x28\x60\x38\x20\x28\x7F\xF8\x2A\xA8\x7F\xF8\x00\x00"
  779.                     );    // zoomup (b/w)
  780.     }
  781. } /* end of DrawZoom() */
  782.  
  783. /*————————————————————
  784.             draw the specified item
  785. ————————————————————*/
  786. DrawOnce( long param, int var, WindowPtr window, Rect windowRect, PatsPtr pat, int drawColor )
  787. {
  788.     Rect        thisRect;
  789.     Handle        theColors;
  790.                 
  791.     theColors = wCTHandle;
  792.     
  793.     switch ( (int)param )
  794.     {
  795.     case ( wNoHit ):
  796.         
  797.         thisRect = windowRect;
  798.  
  799.         PenNormal();
  800.         
  801.         /* ——————————————————————————————————————— now for the more specific parts */
  802.         switch ( var & 7 )
  803.         {
  804.         case ( documentProc ):                    /* a regular window */
  805.         case ( noGrowDocProc ):                    /* a regular window with no grow box */
  806.         case ( movableDBoxProc ):                /* a non-modal dialog */
  807.             if ( drawColor )
  808.                 RGBForeColor( &pat->cBlack );
  809.             PenPat( &pat->black );
  810.             FrameRect( &thisRect );
  811.  
  812.             thisRect.bottom = thisRect.top + 21;
  813.             FrameRect( &thisRect );
  814.             InsetRect( &thisRect, 2, 2 );
  815.             if ( drawColor )
  816.             {
  817.                 if( theWindow.hilited )
  818.                     RGBForeColor( &pat->cBlack );
  819.                 else
  820.                     RGBForeColor( &pat->cLight );
  821.             } else
  822.                 PenPat( &pat->gray );
  823.             PaintRect( &thisRect );
  824.             InsetRect( &thisRect, -1,-1 );
  825.             if ( drawColor )
  826.                 RGBForeColor( drawColor - 1 ? &pat->cFrameD : &pat->cDark );
  827.             else
  828.                 PenPat( &pat->black );
  829.             PenSize( 1, 1 );
  830.             MoveTo( windowRect.left+2, windowRect.top+19 );
  831.             LineTo( windowRect.right-2, windowRect.top+19 );
  832.             LineTo( windowRect.right-2, windowRect.top+2 );
  833.             if ( drawColor )
  834.                 RGBForeColor( drawColor - 1 ? &pat->cFrameL : &pat->cWhite );
  835.             else
  836.                 PenPat( &pat->white );
  837.             MoveTo( windowRect.left+1, windowRect.top+19 );
  838.             LineTo( windowRect.left+1, windowRect.top+1 );
  839.             LineTo( windowRect.right-2, windowRect.top+1 );
  840.  
  841.             /* ——————————————————————————————— the goaway box */
  842.             if ( theWindow.goAwayFlag  && (var & 7) != movableDBoxProc )
  843.             {
  844.                 SetRect( &thisRect, 
  845.                     windowRect.right     - 17, 
  846.                     windowRect.top         + 4,
  847.                     windowRect.right     - 4,
  848.                     windowRect.top         + 17
  849.                  );
  850.                 DrawPane( pat, thisRect, drawColor );
  851.                 DrawGoAway( thisRect, false, drawColor, theColors );        
  852.             }
  853.             /* ——————————————————————————————— the zoom box */
  854.             if ( theWindow.zoomFlag )
  855.             {
  856.                 SetRect( &thisRect, 
  857.                     windowRect.left     + 5, 
  858.                     windowRect.top         + 4,
  859.                     windowRect.left     + 18,
  860.                     windowRect.top         + 17
  861.                  );
  862.                 DrawPane( pat, thisRect, drawColor );
  863.                 DrawZoom( thisRect, false, drawColor, theColors );        
  864.             }
  865.             if ( theWindow.hilited )
  866.             {
  867.                 /* ——————————————————————————————— the title */
  868.                 SetRect( &thisRect, 
  869.                     windowRect.left     + 21, 
  870.                     windowRect.top         + 3,
  871.                     windowRect.right     - 21,
  872.                     windowRect.top         + 17
  873.                  );
  874.                 PenSize( 1, 1 );
  875.                 if ( thisRect.right - thisRect.left > 0 )
  876.                     DrawWindowTitle( window, thisRect, pat, true, drawColor );
  877.             } else
  878.             {
  879.                 /* ——————————————————————————————— the title */
  880.                 SetRect( &thisRect, 
  881.                     windowRect.left     + 21, 
  882.                     windowRect.top         + 3,
  883.                     windowRect.right     - 21,
  884.                     windowRect.top         + 17
  885.                  );
  886.                 if (!drawColor )
  887.                     DrawPane( pat, thisRect, drawColor );
  888.                 DrawWindowTitle( window, thisRect, pat, false, drawColor );
  889.             }
  890.             break;
  891.         
  892.         case ( dBoxProc ):                        /* dialog box variation */
  893.             DrawFrame( pat, thisRect, 4, drawColor );
  894.             thisRect.right -= 2;
  895.             thisRect.bottom -= 2;
  896.             OffsetRect( &thisRect, 1, 1 );
  897.             InsetRect( &thisRect, 5, 5 );
  898.             PenSize( 2, 2 );
  899.             if ( drawColor )
  900.             {
  901.                 PenPat( &pat->black );
  902.                 RGBForeColor( &pat->cLight );
  903.             } else
  904.                 PenPat( &pat->white );
  905.             FrameRect( &thisRect );
  906.             break;
  907.         case ( altDBoxProc ):                    /* shadow box variation */
  908.         case ( altDBoxProc + 4 ):                /* remain consistant w/ Apple */
  909.             thisRect.right -= 2;
  910.             thisRect.bottom -= 2;
  911.             FrameRect( &thisRect );
  912.             PenSize( 2, 2 );
  913.             if ( drawColor )
  914.                 RGBForeColor( &pat->cLight );
  915.             MoveTo( thisRect.left + 2, thisRect.bottom );
  916.             LineTo( thisRect.right, thisRect.bottom );
  917.             LineTo( thisRect.right, thisRect.top + 2 );
  918.             break;
  919.         default:                                /* plain box variation (plainDBox) and others */
  920.             PenPat( &pat->black );
  921.             FrameRect( &thisRect );
  922.             break;
  923.         }
  924.         
  925.         break;
  926.         
  927.     case ( wInGoAway ):
  928.     
  929.         SetRect( &thisRect,                         /* just toggle the goAway */
  930.             windowRect.right     - 17, 
  931.             windowRect.top         + 4,
  932.             windowRect.right     - 4,
  933.             windowRect.top         + 17
  934.          );
  935.         buttonState = !buttonState;
  936.         DrawGoAway( thisRect, buttonState, drawColor, theColors );        
  937.         break;
  938.         
  939.     case ( wInZoomIn ):
  940.     case ( wInZoomOut ):
  941.  
  942.         SetRect( &thisRect,                         /* just toggle the zoomBox */
  943.             windowRect.left     + 5, 
  944.             windowRect.top         + 4,
  945.             windowRect.left     + 18,
  946.             windowRect.top         + 17
  947.          );
  948.         buttonState = !buttonState;
  949.         DrawZoom( thisRect, buttonState, drawColor, theColors );
  950.         break;
  951.         
  952.     default:
  953.         break;
  954.         
  955.     }
  956. } /* end of DrawOnce() */
  957.  
  958. /*————————————————————
  959.             drawing my window
  960. ————————————————————*/
  961. DrawMyWindow( int var, WindowPtr window, long param )
  962. {
  963.     SysEnvRec        thisWorld;
  964.     CGrafPtr        wPort,
  965.                     savePort;
  966.     Boolean            hasColorQD;
  967.     
  968.     PenState        savePen;
  969.     RGBColor        savePnClr,
  970.                     saveBkClr;
  971.     PixPatHandle    savePnPat,
  972.                     saveBkPat,
  973.                     saveFillPat;
  974.  
  975.     PatsRec            patStore;
  976.     PatsPtr            pat;
  977.     
  978.     Rect            windowRect;
  979.     
  980.     savePnPat = nil;
  981.     
  982.     if ( !theWindow.visible ) return;
  983.     
  984.     pat = &patStore;
  985.         
  986.     if ( !SysEnvirons( 1, &thisWorld ) )
  987.         hasColorQD = thisWorld.hasColorQD;
  988.     else
  989.         hasColorQD = false;
  990.         
  991.     
  992.     if ( hasColorQD )
  993.     {
  994.         AuxWinHandle    theAuxWin;
  995.  
  996.         theAuxWin = nil;
  997.  
  998.         GetPort( &savePort );
  999.         GetCWMgrPort( &wPort );
  1000.         SetPort( wPort );
  1001.         
  1002.         savePnPat = NewPixPat();
  1003.         saveBkPat = NewPixPat();
  1004.         saveFillPat = NewPixPat();
  1005.         
  1006.         CopyPixPat( wPort->pnPixPat, savePnPat );
  1007.         CopyPixPat( wPort->bkPixPat, saveBkPat );
  1008.         CopyPixPat( wPort->fillPixPat, saveFillPat );
  1009.         GetForeColor( &savePnClr );
  1010.         GetBackColor( &saveBkClr );
  1011.         
  1012.         pat->cBlack = PackGray( 0 );
  1013.         pat->cDark = PackGray( 0x5000 );
  1014.         pat->cLight = PackGray( 0xA000 );
  1015.         pat->cWhite = PackGray( 0xFFFF );
  1016.         pat->cFrameL = pat->cWhite;
  1017.         pat->cFrameD = pat->cDark;
  1018.         
  1019.         GetAuxWin( window, &theAuxWin );
  1020.         if ( theAuxWin )
  1021.         {
  1022.             HLockHi( (*theAuxWin)->awCTable );
  1023.                                 
  1024.     /*        The code below makes sure the System 7 colors are found even when the window color
  1025.                 table is defined with only 5 colors! This defines the outline colors of the
  1026.                 frame and buttons.    */
  1027.                 
  1028.             if ( auxCTable->ctSize < 12 )
  1029.                 GetAuxWin( nil, &theAuxWin );
  1030.             if ( auxCTable->ctSize >= 12 )
  1031.             {            
  1032.                 if ( auxCTable->ctTable[12].rgb.red + auxCTable->ctTable[12].rgb.green )
  1033.                 {
  1034.                     if ( !wCTHandle )    // Make Color Table Now, if not done...
  1035.                     {                                // We only use a ColorTable if System 7
  1036.                         Handle            theColors;
  1037.         
  1038.                         theColors = nil;
  1039.                         theColors = NewHandle( 40 );                // theColorTable!
  1040.  
  1041.                         if ( theColors )
  1042.                         {
  1043.                             int            i;
  1044.                     
  1045.                             HLock( theColors );
  1046.                             
  1047.                             (*(CTabHandle)theColors)->ctSeed = GetCTSeed();    //    Unique Seed
  1048.                             (*(CTabHandle)theColors)->ctFlags = 0;            //    Empty for CTables
  1049.                             (*(CTabHandle)theColors)->ctSize = 3;            //    4 Colors
  1050.                     
  1051.                             for ( i=0; i<=3; i++ )                            // Colors in sequence
  1052.                                 (*(CTabHandle)theColors)->ctTable[i].value = i;
  1053.                                 
  1054.                             (*(CTabHandle)theColors)->ctTable[1].rgb = pat->cLight;
  1055.                             (*(CTabHandle)theColors)->ctTable[3].rgb = pat->cBlack;
  1056.                             
  1057.                             HUnlock( theColors );
  1058.                             wCTHandle = theColors;
  1059.                         }
  1060.                     } else
  1061.                     if( (auxCTable->ctTable[12].rgb.red &
  1062.                             auxCTable->ctTable[12].rgb.green &
  1063.                             auxCTable->ctTable[12].rgb.blue) != 0x3333 ) // disable Color Table if gray.
  1064.                     {
  1065.                         pat->cFrameL =  auxCTable->ctTable[11].rgb;
  1066.                         pat->cFrameD =  auxCTable->ctTable[12].rgb;
  1067.                     }
  1068.                     if ( wCTHandle )        // update Icon colors for Sys 7
  1069.                     {
  1070.                         (*(CTabHandle)(wCTHandle))->ctTable[0].rgb = pat->cFrameL;
  1071.                         (*(CTabHandle)(wCTHandle))->ctTable[2].rgb = pat->cFrameD;
  1072.                     }
  1073.                 } else
  1074.                     hasColorQD=false;
  1075.             }
  1076.             HUnlock( (*theAuxWin)->awCTable );
  1077.         }
  1078.     }
  1079.     
  1080.     windowRect = (**theWindow.strucRgn).rgnBBox;
  1081.     
  1082. /*    Align the pattern to the position of the window to prevent shifting durring a drag. */
  1083.         
  1084.     pat->gray[0] = pat->gray[1] = (windowRect.left^windowRect.top) & 0x0001
  1085.         ?gray1Hex
  1086.         :gray2Hex;
  1087.     
  1088.     pat->black[0] = pat->black[1] = blackHex;
  1089.     pat->white[0] = pat->white[1] = whiteHex;
  1090.     GetPenState( &savePen );
  1091.     
  1092.     if ( hasColorQD )
  1093.     {
  1094.         RgnHandle    saveClip,
  1095.                     tempRgn;
  1096.         GDHandle    aDevice;
  1097.         
  1098.         saveClip = NewRgn();
  1099.         tempRgn = NewRgn();
  1100.         GetClip( saveClip );
  1101.  
  1102.         aDevice = GetDeviceList();
  1103.         do
  1104.         {
  1105.             if ( TestDeviceAttribute( aDevice, screenDevice ) &&
  1106.                                             TestDeviceAttribute( aDevice, screenActive ) )
  1107.             {
  1108.                 HLockHi( aDevice );
  1109.                 if ( RectInRgn( &(**aDevice).gdRect, saveClip ) )
  1110.                 {
  1111.                     RectRgn( tempRgn, &(**aDevice).gdRect );
  1112.                     SectRgn( saveClip, tempRgn, tempRgn );
  1113.                     SetClip( tempRgn );
  1114.                     DrawOnce( param, var, window, windowRect, pat,
  1115.                                                     ((**(**aDevice).gdPMap).cmpSize - 1 ));
  1116.                 }
  1117.                 HUnlock( aDevice);
  1118.             }
  1119.         } while ( (aDevice = GetNextDevice( aDevice )) != nil );
  1120.     
  1121.         SetClip( saveClip );
  1122.         DisposeRgn( saveClip );
  1123.         DisposeRgn( tempRgn );
  1124.     } else
  1125.         DrawOnce( param, var, window, windowRect, pat, 0 );
  1126.     
  1127.     SetPenState( &savePen );
  1128.     if ( savePnPat )        // Since hasColorQD may have changed, we check for presence of Handle.
  1129.     {
  1130.         RGBForeColor( &savePnClr );
  1131.         RGBBackColor( &saveBkClr );
  1132.         
  1133.         CopyPixPat( savePnPat, wPort->pnPixPat );
  1134.         CopyPixPat( saveBkPat, wPort->bkPixPat );
  1135.         CopyPixPat( saveFillPat, wPort->fillPixPat );
  1136.         DisposPixPat( savePnPat );
  1137.         DisposPixPat( saveBkPat );
  1138.         DisposPixPat( saveFillPat );
  1139.         
  1140.         SetPort( savePort );
  1141.     }
  1142. } /* end of DrawMyWindow() */
  1143.  
  1144. /*————————————————————
  1145.             draw a black and white Icon!
  1146. ————————————————————*/
  1147. PlotSICN( Rect theRect, Ptr theSICN )
  1148. {
  1149.     BitMap    srcBits;    /* built up around 'SICN' data so we can _CopyBits */
  1150.     GrafPtr    wPort;
  1151.     
  1152.     GetPort( &wPort );
  1153.  
  1154.     /* set up the small icon's bitmap */
  1155.     srcBits.baseAddr = theSICN;
  1156.     srcBits.rowBytes = 2;
  1157.     SetRect( &srcBits.bounds, 0, 0, 13, 13 );
  1158.  
  1159.                                 /* draw the small icon in the current grafport */
  1160.     CopyBits( &srcBits,&wPort->portBits,&srcBits.bounds,&theRect,srcCopy,nil );
  1161.  
  1162. } /* end of PlotSICN() */
  1163.  
  1164. /*————————————————————
  1165.             draw a color icon!
  1166. ————————————————————*/
  1167. PlotCICN( Rect theRect, Ptr theCICN, Handle theColors )
  1168. {
  1169.     PixMap            srcBits;    // built up around 'CICN' data so we can _CopyBits
  1170.      CGrafPtr        wPort;            
  1171.     RGBColor        savePnClr,
  1172.                     saveBkClr,
  1173.                     myRGB;
  1174.  
  1175.     GetForeColor( &savePnClr );
  1176.     myRGB = PackGray( 0x0000 );
  1177.     RGBForeColor( &myRGB );            // Black
  1178.     GetBackColor( &saveBkClr );
  1179.     myRGB = PackGray( 0xFFFF );
  1180.     RGBBackColor( &myRGB );            // White
  1181.  
  1182.      GetPort( &wPort );
  1183.      
  1184.     srcBits.baseAddr = theCICN;
  1185.      srcBits.rowBytes = 0x8004;        // bit 15 indicates PixMap
  1186.      SetRect( &srcBits.bounds, 0, 0, 13, 13 );
  1187.      srcBits.pmVersion = srcBits.packType = srcBits.pixelType = 0;
  1188.      srcBits.packSize = srcBits.planeBytes = srcBits.pmReserved = 0L;
  1189.      srcBits.hRes = srcBits.vRes = 72;
  1190.     srcBits.pixelSize = srcBits.cmpSize = 2;
  1191.      srcBits.cmpCount = 1;     
  1192.      srcBits.pmTable = (CTabHandle)theColors;                        // nil if not created
  1193.     
  1194.                                      //    draw the color icon in the current grafport
  1195.      CopyBits( &srcBits,*wPort->portPixMap,&srcBits.bounds,&theRect,srcCopy,nil );
  1196.      
  1197.     RGBForeColor( &savePnClr );
  1198.     RGBBackColor( &saveBkClr );
  1199.     
  1200. } /* end of PlotCICN() */
  1201.  
  1202. /*————————————————————
  1203.             CopyRight Notice
  1204. ————————————————————*/
  1205. CopyRight()
  1206. {
  1207.     /*    The Following Copyright Notice Is Not To Be Removed! Use Of This Code In Commercial
  1208.         Software Will Be By License Only. Contact Anthony D. Saxton, Of Elenay™ Creations
  1209.         For Licensing Information. Use Of This Code In FreeWare, Requires Only Contact Of
  1210.         Elenay™ Creations. This Copyright Applies To All Code Segments Of This WDEF. */
  1211.         
  1212.     Str63    Copyright = "Copyright©1993–Elenay™Creations,702/453–0270,"
  1213.                                 "All Rights Reserved";
  1214.     
  1215. }